/**
 * 
 */
package cn.tonyqiu.wonuly.service.impl;

import java.util.List;

import cn.tonyqiu.wonuly.dao.AccountDao;
import cn.tonyqiu.wonuly.dao.BillDao;
import cn.tonyqiu.wonuly.dao.CategoryDao;
import cn.tonyqiu.wonuly.dao.UserDao;
import cn.tonyqiu.wonuly.model.Bill;
import cn.tonyqiu.wonuly.model.User;
import cn.tonyqiu.wonuly.service.BillManager;
import cn.tonyqiu.wonuly.service.util.UserServiceUtil;

/**
 * @author <a href="mailto:tony.qiu.smart@gmail.com">Tony Qiu</a>
 *
 */


public class BillManagerImpl extends GenericManagerImpl<Bill, Integer> implements BillManager {

	private UserDao userDao;
	private BillDao billDao;
	private CategoryDao categoryDao;
	private AccountDao accountDao;
	
	private User user;
	
	/**
	 * @return the categoryDao
	 */
	public CategoryDao getCategoryDao() {
		return categoryDao;
	}

	/**
	 * @param categoryDao the categoryDao to set
	 */
	public void setCategoryDao(CategoryDao categoryDao) {
		this.categoryDao = categoryDao;
	}

	/**
	 * @return the accountDao
	 */
	public AccountDao getAccountDao() {
		return accountDao;
	}

	/**
	 * @param accountDao the accountDao to set
	 */
	public void setAccountDao(AccountDao accountDao) {
		this.accountDao = accountDao;
	}

	/**
	 * @return the userDao
	 */
	public UserDao getUserDao() {
		return userDao;
	}

	/**
	 * @param userDao the userDao to set
	 */
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	/**
	 * @return the billDao
	 */
	public BillDao getBillDao() {
		return billDao;
	}

	/**
	 * @param billDao the billDao to set
	 */
	public void setBillDao(BillDao billDao) {
		this.billDao = billDao;
	}

	/* (non-Javadoc)
	 * @see cn.tonyqiu.wonuly.service.BillManager#getBillsByUser()
	 */
	@Override
	public List<Bill> getBillsByUser(){
		if(user == null) user = userDao.getUserByEmail(UserServiceUtil.getUserEmail());
		List<Bill> bills = billDao.getBillsByUserId(user.getId());
		return bills;
	}

}
